
public class DuckSimulator {
	public static void main(String[] args){
		DuckSimulator sim = new DuckSimulator();
		AbstractDuckFactory duckFactory = new CountingDuckFactory();
		sim.simulate(duckFactory);
	}
	
	void simulate(AbstractDuckFactory duckFactory){
		Quackable redHeadDuck = duckFactory.createRedHeadDuck();
		Quackable duckCall= duckFactory.createDuckCall();
		Quackable rubberDuck = duckFactory.createRubberDuck();
		
		Quackable gooseDuck = new GooseAdaptor(new Goose());
		
		System.out.println("\nDuck Sim #5 How may time Quacks? Using Compositern");
		
		Flock flockOfDucks = new Flock();
		flockOfDucks.add(redHeadDuck);
		flockOfDucks.add(duckCall);
		flockOfDucks.add(rubberDuck);
		flockOfDucks.add(gooseDuck);
		
		Flock flockOfMallardDucks = new Flock();
		Quackable mallardDuck1 = duckFactory.createMallardDuck();
		Quackable mallardDuck2 = duckFactory.createMallardDuck();
		Quackable mallardDuck3 = duckFactory.createMallardDuck();
		Quackable mallardDuck4 = duckFactory.createMallardDuck();
		flockOfMallardDucks.add(mallardDuck1);
		flockOfMallardDucks.add(mallardDuck2);
		flockOfMallardDucks.add(mallardDuck3);
		flockOfMallardDucks.add(mallardDuck4);
		
		flockOfDucks.add(flockOfMallardDucks);
		
		System.out.println("\nDuck Sim #5 How may time Quacks? Whole Duck Flock");
		simulate(flockOfDucks);
		
		System.out.println("\nDuck Sim #5 How may time Quacks? Mallard Flock");
		simulate(flockOfMallardDucks);
		
		System.out.println("\nThs Ducks Quacked " + QuackCounter.getQuacks() + " Times");
	}
	
	void simulate( Quackable duck){
		duck.Quack();
	}
	

}
